public class Display {
	public static boolean Lsearch=true; 
	public static boolean PSearch=true;
	public static boolean SRestore=false;
	public static boolean SLRestore=false;
	private InputIO in=new InputIO();
	public void menu(){
		System.out.println("");	
	}	
	public void PrintLine(int line){
		String s="====================================================================================";
		String str=s.substring(0,line);
		System.out.println(str);
	}
	//========= display menu on screen =========
	public void displayMenu(){
		PrintLine(72);
		if(!SRestore){
			if(Lsearch)
				System.out.println(" 5.[R]ead  6.[W]rite  7.[D]elete  8.[U]pdate  9.Restore  S.[S]earch   E. Exit");
			else
				System.out.println(" 5.[R]ead  6.[W]rite  7.[D]elete  8.[U]pdate  9.Restore  S.[S]earch   M. Main...");
		}
		else{
			if(SLRestore==false)
				System.out.println(" 7.[D]elete   9.Restore   S.[S]earch   M.Main...");
			else
				System.out.println(" 7.[D]elete   9.Restore   S.[S]earch   B.main Restore...  M.Main...");
		}
		PrintLine(80);
		System.out.print("Choose : ");
	}
	//==== list for selecting pagination =========
	protected void showSelectPagination(){	
		PrintLine(67);
		System.out.println(" P.Set Rows  0.First  1.Previose  2.Next  3.Last  4.[N]ext To Page");
	}
	//==== list for selecting articles =========
	public void showChooseField(){
		System.out.println("-------------------------------------------------------------------");
		System.out.println("=====================================");
		System.out.println("1.Title 2.Author 3.Content 4.Exit... ");
		System.out.println("=====================================");
		System.out.print("Choose:");
	}
	//==== display for inputting new articles =========
	public void displayInsertData(String title,String author,String content){
		String st[]=new String[3];
		System.out.println("=>  Please Input new Artical ");
		System.out.println("--------------------------------------------------------------------------");
		do{
			System.out.print("Title    :  ");
			title=in.input();
			if(st[0].trim().length()<=0)continue;
			else break;
		}while(true);
		do{
			System.out.print("Author   :  ");
			author=in.input();
			if(author.trim().length()<=0)continue;
			else break;
		}while(true);
		do{
			System.out.println("		 	     Content ");
			System.out.println("--------------------------------------------------------------------------");
			content=in.inputMultiLine();
			if(content.trim().length()<=0)continue;
			else break;
		}while(true);
	}
	//==== display for reading data =========
	public void displayReadData(Artical ar){
		System.out.println("--------------------------------------------------------------------------");
		System.out.println("ID       :  "+ar.getId());
		System.out.println("Title    :  "+ar.getTitle());
		System.out.println("Author   :  "+ar.getAuthor());
		System.out.println("Date     :  "+ar.getDate());
		System.out.println("		 	     Content ");
		System.out.println("--------------------------------------------------------------------------");
		if(ar.getContent().length()>2000){
			System.out.println(showDetail(ar.getContent(), 1000));
			System.out.println();
			if(ContinueOrNot("Do you want to show detail ?(y/Any key...)")){
				System.out.println(ar.getContent().substring(1000,ar.getContent().length()));
			}
		}
		else System.out.println(ar.getContent());

	}
	//==== input id =========
	public int InputId(String s){
		System.out.print(s);
		int i=in.inputNumber();
		if(in.CheckId(i)==-2)return -2;
		return i;
	}
	public void ShowSelectMenu(){
		showSelectPagination();
		displayMenu();
	}
	public boolean ContinueOrNot(String str){
		System.out.print(str);
		String s=in.input();
		if(s.contains("y"))
			return true;
		return false;
	}
	public static void ClearScreen(int count){
		for(int i=0;i<count;i++)
			System.out.println("                                            ");
		
	}
	public static String showDetail(String s,int i){
		String str="";
		if(s.length()>i){
			str=s.substring(0,i);
			str+=".....";
			return str;
		}
		return s;
	}
}
